<template>
  <div>
    <input v-model="msg">
    <p>prop: {{propMessage}}</p>
    <p>msg: {{msg}}</p>
    <p>helloMsg: {{helloMsg}}</p>
    <p>computed msg: {{computedMsg}}</p>
    <button @click="greet">Greet</button>
  </div>
</template>

<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
@Component({
  props: {
    propMessage: String,
  },
})
export default class App extends Vue {
  propMessage: string
  // inital data
  msg: number = 123
  // use prop values for initial data
  helloMsg: string = `Hello, ${this.propMessage}`
  // helloMsg: string = 'Hello, ' + this.propMessage
  // lifecycle hook
  mounted() {
    this.greet();
  }
  // computed
  get computedMsg() {
    return `computed ${this.msg}`;
    // return 'computed ' + this.msg
  }
  // method
  greet() {
    console.log(`Hello, typescript ${this.msg}`);
    //  console.log('Hello, typescript ' + this.msg)
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  display: inline-block;
  margin: 0 10px;
}

a {
  color: #42b983;
}
</style>
